#!/usr/bin/env python

import re

def Config(DeviceName,SortType,FileConfig):
    
    
    Version=""
    Patch =""
    TestItemNum=""
    DigitalTestItemNum=""
    TestItenNames=""
    FlagConfig=1
    
    FileConfigFH=open(FileConfig)
    Lines = FileConfigFH.readlines()
    
    for Line in Lines:
        
        if re.search(DeviceName,Line,2) and re.search(SortType,Line,2):
            
            
            Line=Line.rstrip()
            TempArray=re.split(r":",Line)
            Version=TempArray[2]
            Patch=TempArray[3]
            TestItemNum=TempArray[4]
            DigitalTestItemNum=TempArray[5]
            TestItemNames=TempArray[6]
            FlagConfig=0
    
    if not(FlagConfig):
        return(FlagConfig,Version,Patch,TestItemNum,DigitalTestItemNum,TestItemNames)
    else:
        print ("Can't find the device: %s 's configure in configure file,please add its configure to configure file!\n" % DeviceName)
        return (FlagConfig)
    
def main():    
    
    Temp=Configure("HED0409","Sort1","configure")
        

if __name__ == '__main__':
    main()
